<?php

namespace PointPresse\BlogBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
 * Post
 *
 * @ORM\Table()
 * @ORM\Entity(repositoryClass="PointPresse\BlogBundle\Entity\PostRepository")
 * @ORM\Table(name="post")
 */
class Post
{
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var string
     *
     * @ORM\Column(name="subject", type="string", length=255, nullable=false)
     * @Assert\NotBlank(message="Le titre ne peut pas être vide.")
     */
    private $subject;

    /**
     * @var string
     *
     * @ORM\Column(name="content", type="text", nullable=true)
     */
    private $content;

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="datePost", type="datetime", nullable=false)
     */
    private $datePost;

    /**
     * @var integer
     *
     * @ORM\Column(name="idCat", type="integer", nullable=false)
     */
    private $idCat;

    /**
     * @ORM\ManyToOne(targetEntity="PointPresse\BlogBundle\Entity\Journalist",inversedBy="posts", cascade={"persist"})
     */
    private $journalist;


	
	public function __construct($s=null,$c=null,$idc=null,$d=null)
    {
	$this->subject=$s;
	$this->content=$c;
      
        $this->setDatePost($d);
	$this->idCat=$idc;
		
	}
        
	
    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set subject
     *
     * @param string $subject
     * @return Post
     */
    public function setSubject($subject)
    {
        $this->subject = $subject;
    
        return $this;
    }

    /**
     * Get subject
     *
     * @return string 
     */
    public function getSubject()
    {
        return $this->subject;
    }

    /**
     * Set content
     *
     * @param string $content
     * @return Post
     */
    public function setContent($content)
    {
        $this->content = $content;
    
        return $this;
    }

    /**
     * Get content
     *
     * @return string 
     */
    public function getContent()
    {
        return $this->content;
    }

    /**
     * Set datePost
     *
     * @param \DateTime $datePost
     * @return Post
     */
    public function setDatePost($datePost)
    {
        if($datePost != null)
        {
           $this->datePost= $datePost; 
        }
        else
        {
            $this->datePost=new \datetime();
        }       
    
        return $this;
    }

    /**
     * Get datePost
     *
     * @return \DateTime 
     */
    public function getDatePost()
    {
        return $this->datePost;
    }

    /**
     * Set idCat
     *
     * @param integer $idCat
     * @return Post
     */
    public function setIdCat($idCat)
    {
        $this->idCat = $idCat;
    
        return $this;
    }

    /**
     * Get idCat
     *
     * @return integer 
     */
    public function getIdCat()
    {
        return $this->idCat;
    }


    /**
     * Set journalist
     *
     * @param \PointPresse\BlogBundle\Entity\Journalist $journalist
     * @return Post
     */
    public function setJournalist(\PointPresse\BlogBundle\Entity\Journalist $journalist = null)
    {
        $this->journalist = $journalist;
        $journalist->addPost($this);
    
        return $this;
    }

    /**
     * Get journalist
     *
     * @return \PointPresse\BlogBundle\Entity\Journalist 
     */
    public function getJournalist()
    {
        return $this->journalist;
    }
}